import http from "../request";
const apibase = "/api/DataSource";

//获取数据来源
var getDataSources = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetDataSourcesToKeyWord`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//添加数据源
var addDataSource = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/InsDataSource`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//修改数据源
var updateDataSource = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/UpdDataSource`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//删除数据源
var deleteDataSource = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/DelDataSource`,data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

export { getDataSources, deleteDataSource, updateDataSource, addDataSource };
